package com.ctg.itrdc.sysmgr.portal.data.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Component;

import com.ctg.itrdc.pasp.core.PageInfo;
import com.ctg.itrdc.pasp.data.dao.BaseDao;
import com.ctg.itrdc.sysmgr.portal.data.ISystemRolesDao;
import com.ctg.itrdc.sysmgr.portal.data.entity.SystemRoles;
import com.ctg.itrdc.sysmgr.portal.data.vo.SystemRolesVO;

@Component("systemRolesDao")
public class SystemRolesDaoImpl extends BaseDao<SystemRoles, Long> implements ISystemRolesDao {

	public List<SystemRoles> selectBySysUserId(Long sysUserId) {
		Map<String, Object> model = new HashMap<String, Object>(1);
		model.put("userId", sysUserId);
		return queryBySqlId("selectBySysUserId", model);
	}
	
	public Long[] selectRoleIdsBySysUserId(Long sysUserId) {
		List<SystemRoles> sysUserRoles = selectBySysUserId(sysUserId);
		Long[] array = new Long[sysUserRoles.size()];
		for (int i = 0; i < sysUserRoles.size(); i++) {
			array[i] = sysUserRoles.get(i).getSysRoleId();
		}
		return array;
	}
	
	public List<SystemRoles> selectBySysPostId(Long sysPostId) {
		Map<String, Object> model = new HashMap<String, Object>(1);
		model.put("postId", sysPostId);
		return queryBySqlId("selectBySysPostId", model);
	}
	
	public Long[] selectRoleIdsBySysPostId(Long sysPostId) {
		List<SystemRoles> sysPostRoles = selectBySysPostId(sysPostId);
		Long[] array = new Long[sysPostRoles.size()];
		for (int i = 0; i < sysPostRoles.size(); i++) {
			array[i] =sysPostRoles.get(i).getSysRoleId() ;
			
		}
		return array;
	}

	@Override
	public PageInfo<SystemRolesVO> queryPageInfo4Post(SystemRoles entity,
			Long sysPostId, Integer currentPage, Integer perPageNum) {
		Map<String, Object> model = new HashMap<String, Object>(2);
		model.put("sr", entity);
		model.put("sysPostId", sysPostId);
		return pageBySqlId("queryPageInfo4Post", SystemRolesVO.class, currentPage, perPageNum, model, null);
	}

	@Override
	public PageInfo<SystemRolesVO> queryPageInfo4User(SystemRoles entity,
			Long sysUserId, Integer currentPage, Integer perPageNum) {
		Map<String, Object> model = new HashMap<String, Object>(2);
		model.put("sr", entity);
		model.put("sysUserId", sysUserId);
		return pageBySqlId("queryPageInfo4User", SystemRolesVO.class, currentPage, perPageNum, model, null);
	}
	
	
}